<?php
class Team extends DataObject {
	static $db = array(
		"Title" => "Varchar(255)",
		"Description" => "Text",
	);
	
	static $has_one = array(
		"Logo" => "Image"
	);
	
	static $has_many = array("FoulPoints"=>"FoulPoint");
	
   static $belongs_many_many = array(
      'Leagues' => 'League'
   );
	
   static $default_sort = 'Title ASC'; 
	
   static $searchable_fields = array(
      'Title',
      'Description' 
   );

   
   public function FoulPoints() {
   	    $ret = DataObject::get('FoulPoint','TeamID = ' . $this->ID . ' AND LeagueID = ' . $this->ParentLeague->ID);
   	    return $ret;
   }
   
   public function FairPlayFoulPoints() {
        $ret = DataObject::get('FairPlayFoulPoint','TeamID = ' . $this->ID . ' AND LeagueID = ' . $this->ParentLeague->ID);
        return $ret;
   }
   
	
	
	
}
